define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'uniwigs/cashcoderule/index',
                    add_url: 'uniwigs/cashcoderule/add',
                    edit_url: 'uniwigs/cashcoderule/edit',
                    del_url: 'uniwigs/cashcoderule/del',
                    multi_url: 'uniwigs/cashcoderule/multi',
                    table: 'cash_code_rule',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id_code_rule',
                sortName: 'id_code_rule',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id_code_rule', title: __('Id_code_rule')},
                        {field: 'category', title: __('Category'), visible:false, searchList: {"\u65e0\u9650\u5236":__('\u65e0\u9650\u5236'),"\u5173\u952e\u5b57\u9650\u5236":__('\u5173\u952e\u5b57\u9650\u5236'),"\u65e5\u671f\u9650\u5236":__('\u65e5\u671f\u9650\u5236'),"\u91d1\u989d\u9650\u5236":__('\u91d1\u989d\u9650\u5236')}},
                        {field: 'category_text', title: __('Category'), operate:false},
                        {field: 'group_name', title: __('Group_name')},
                        {field: 'description', title: __('Description')},
                        {field: 'condition', title: __('Condition')},
                        {field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
                      //  {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});